package helper

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Response(ctx *gin.Context, data any, err error) {
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"message": err.Error(),
			"code":    1001,
		})
	} else {
		ctx.JSON(http.StatusOK, gin.H{
			"message": "success",
			"data":    data,
			"code":    0,
		})
	}
	ctx.Abort()
}
